Skip to content

Conversation

@kristijanhusak
Copy link
Member

@kristijanhusak kristijanhusak commented Nov 26, 2025

Summary

Add support for showing inline math with tree-sitter, and also render it with Snacks image module.

Related Issues

Related: #1056

Changes

  • Increase required tree-sitter-org version to 2.0.2
  • Add highlights for new captures
  • Add captures for Snacks image

Checklist

I confirm that I have:

  • Followed the
    Conventional Commits
    specification
    (e.g., feat: add new feature, fix: correct bug,
    docs: update documentation).
  • My PR title also follows the conventional commits specification.
  • Updated relevant documentation, if necessary.
  • Thoroughly tested my changes.
  • Added tests (if applicable) and verified existing tests pass with
    make test.
  • Checked for breaking changes and documented them, if any.

@NickHu
Copy link

NickHu commented Dec 1, 2025

Thanks for getting round to this. With these changes, I can indeed observe an image preview for inline math (make sure to set conceallevel=2).

Test file:

Here is a test: \( a \)


\[
x + 2 = 3
\]

#+BEGIN_SRC math
\LaTeX
#+END_SRC
image

I think it's pretty important for the preview to swallow the surrounding math delimeters (\(,\[,\),\]) though — the output is much more readable that way and it also matches how Snacks behaves on actual .tex files.

\documentclass{article}
\begin{document}
Here is a test \( a \)

\[
  x + 2 = 3
\]

\LaTeX
\end{document}
image

@kristijanhusak
Copy link
Member Author

I updated the queries to capture the whole latex content, as you suggested. I think it should be fine now.

screenshot_2025_12_02_17_56_41

Let me know how it works for you.

@NickHu
Copy link

NickHu commented Dec 3, 2025

Looks good to me!

I'd like to take a crack at supporting $x$-style inline math in the near future, which I think will require changes to the tree sitter parser scanner, but from what I can tell it then should just work.

@kristijanhusak
Copy link
Member Author

Awesome, thanks!

@kristijanhusak kristijanhusak merged commit e4e48b5 into master Dec 3, 2025
11 checks passed
@kristijanhusak kristijanhusak deleted the latex-inline-support branch December 3, 2025 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants